export interface Result<T = any> {
  success: boolean;
  data: T;
  message: string;
}

export interface Product {
  id?: number;
  price: number;
  title: string;
  pic: string;
}

export interface ProductResponse extends Product {
  commentCount: number;
  salesVolume: number;
}

export interface ProductListResponse {
  currentPage: number;
  totalPages: number;
  totalCount: number;
  products: ProductResponse[];
}

export interface User {
  id: number;
  userName: string;
  password: string;
  email: string;
  avatar: string;
  createTime: string;
}

export interface LoginRequest {
  userName: string;
  password: string;
}

export interface RegisterRequest extends LoginRequest {
  email: string;
  avatar: string;
}

export interface LoginResponse {
  message: string;
  token: string;
  id: string;
  userName: string;
  avatar: string;
  email: string;
  createTime: string;
}

export interface RegisterResponse {
  message: string;
  user: User;
}

export interface Order {
  id: number;
  code: string;
  totalPrice: number;
  status: number;
  updateTime: string;
  createTime: string;
  userName: string;
  avatar: string;
  products: {
    pic: string;
    price: number;
    productId: number;
    quantity: number;
    title: string;
  }[];
  deliveryAddress: Address;
}

export interface PaginatedOrdersResponse {
  currentPage: number;
  totalPages: number;
  totalCount: number;
  orders: Order[];
}

export interface NewOrder {
  userId: number;
  totalPrice: number;
  items: Array<{ productId: number; quantity: number; price: number }>;
  addressId: number;
}

export interface Comment {
  id: number;
  userId: number;
  productId: number;
  content: string;
  rate: number;
  userName: string;
  avatar: string;
  createTime: string;
}

export enum ORDER_STATUS {
  WAIT_DELIVERY = 1, // 待发货
  DELIVERED = 2, // 已发货
  FINISHED = 3, // 已完成
}

export interface Address {
  id?: number; // 可选，因为在创建新地址时不需要提供ID
  userId: number;
  contacts: string;
  address: string;
  phone: string;
  isDefault: number;
}
